//
//  GYHomeMarketListCell.m
//  GYDemo
//
//  Created by Mrzhang on 2018/3/29.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYHomeMarketListCell.h"
#import "Head.h"

@interface GYHomeMarketListCell ()<GCAdaptLabelDelegate>
@property (nonatomic,strong) GCAdaptLabel *nameLB;
@property (nonatomic,strong) GCAdaptLabel *typeLB;
@property (nonatomic,strong) UILabel *dateLB;
@end

@implementation GYHomeMarketListCell

-(GCAdaptLabel *)nameLB
{
    if (!_nameLB) {
        _nameLB = [[GCAdaptLabel alloc]initWithMaxWidth:WFCGFloatX(375-24)];
        _nameLB.x = WFCGFloatX(16);
        _nameLB.y = WFCGFloatY(11);
        _nameLB.width = WFCGFloatX(375-32);
        
        _nameLB.font = SYSTEMFONT(17);
        _nameLB.textColor = Main_Color_Black;
        _nameLB.numberOfLines=2;
        _nameLB.delegate = self;
    }
    return _nameLB;
}
-(GCAdaptLabel *)typeLB
{
    if (!_typeLB) {
        _typeLB = [[GCAdaptLabel alloc]initWithMaxWidth:WFCGFloatX(60)];
        _typeLB.x = WFCGFloatX(16);
        
        _typeLB.width = WFCGFloatX(145.5);
        _typeLB.height = WFCGFloatY(16.5);
        _typeLB.font = SYSTEMFONT(12);
        _typeLB.textColor = Main_Color_LightGray;
        //[WFFunctions WFUIaddbordertoView:_typeLB radius:WFCGFloatY(3) width:0.7f color:Main_Color_Red];
        _typeLB.delegate = self;
    }
    return _typeLB;
}

-(UILabel *)dateLB
{
    if (!_dateLB) {
        _dateLB = [[UILabel alloc]init];
        _dateLB.x = WFCGFloatX(100);
        
        _dateLB.width = WFCGFloatX(100);
        _dateLB.height = WFCGFloatY(16.5);
        _dateLB.textColor = Main_Color_LightGray;
        _dateLB.font = SYSTEMFONT(10);
        _dateLB.textAlignment = NSTextAlignmentLeft;
       // [WFFunctions WFUIaddbordertoView:_dateLB radius:WFCGFloatY(3) width:0.5f color:Main_Color_LightGray];
    }
    return _dateLB;
}
-(void)setModel:(GYHomeMarketInfoModel *)model
{
    _model = model;
    _nameLB.text = _model.title;
    
    CGSize nameSize=[WFFunctions WFStrGetSize:_model.title width:WFCGFloatX(375-32) font:SYSTEMFONT(17)];
    
    _nameLB.height = nameSize.height;
    
    _typeLB.y = WFCGFloatY(11)+nameSize.height+WFCGFloatY(10);
    _dateLB.y = WFCGFloatY(11)+nameSize.height+WFCGFloatY(10);
    
    _typeLB.text = [NSString stringWithFormat:@"%@",_model.typename];
    _dateLB.text =[WFFunctions WFTimeGetString:[NSDate dateWithTimeIntervalSince1970:_model.inserttime/1000] byFormatter:@"yyyy-MM-dd"];
}
#pragma mark - event
#pragma mark - method
+(CGFloat)finalHeight
{
    return WFCGFloatY(91);
}
#pragma mark - life

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.nameLB];
        [self.contentView addSubview:self.typeLB];
        [self.contentView addSubview:self.dateLB];
 
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
#pragma mark - delegate
-(void)callback:(id)sender
{
    _dateLB.x = _typeLB.right + WFCGFloatX(5);

}
@end
